package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"net/http"
)

//请求参数获取:三种方式
func main(){
	engine := gin.Default()
	engine.GET("/get", func(c *gin.Context) {
		fmt.Println(c.Query("username"))
		fmt.Println(c.Query("password"))
		c.String(http.StatusOK,"get")
	})

	engine.POST("/post", func(c *gin.Context) {
		fmt.Println(c.PostForm("username"))
		fmt.Println(c.PostForm("password"))
		c.String(http.StatusOK,"post")
	})
	
	engine.GET("/get_user/:id", func(c *gin.Context) {
		fmt.Println(c.Param("id"))
		c.String(http.StatusOK,"url param")
	})

	engine.Run()
}
